;;; -*-Lisp-*-

; Version standard-prelude-3.dast-5
; A bare-bones standard prelude for project 3.

;; __builtin__ should not appear in the symbol table.  For our Python
;; subset, it is not directly accessible.
(moduledecl 1 __builtin__)

;; The following declarations (and all those in module __builtin__) 
;; SHOULD be visible in any program.

;; Predefined classes.  

(classdecl 2 Int 1 0 (index_list))
(classdecl 3 String 1 0 (index_list))
(classdecl 4 List 1 0 (index_list))
(classdecl 5 Tuple 1 0 (index_list))
(classdecl 6 Dict 1 0 (index_list))
(classdecl 7 Bool 1 0 (index_list))
(classdecl 8 File 1 0 (index_list))
(classdecl 9 Xrange 1 0 (index_list))

;; User types inherit from object.  
(classdecl 10 object 1 0 (index_list 23))

;; (Looking ahead to Python 3), the variables None, True, and False are not
;; assignable.
(constdecl 11 None 1 (type 0))
(constdecl 12 True 1 (type 7))
(constdecl 13 False 1 (type 7))

;; Assorted functions
(funcdecl 14 abs 1 (functype (type 2) (type 2)))
(funcdecl 15 bool 1 (functype (type 7) (type 0)))
(funcdecl 16 chr 1 (functype (type 3) (type 2)))
(funcdecl 17 cmp 1 (functype (type 2) (type 0) (type 0)))
(funcdecl 18 len 1 (functype (type 2) (type 0)))
(funcdecl 19 list 1 (functype (type 4) (type 0)))

;; Since we don't have optional parameters, we'll use open with two 
;; parameters.
(funcdecl 20 open 1 (functype (type 8) (type 3) (type 3)))

(funcdecl 21 ord 1 (functype (type 2) (type 3)))

;; Two-argument version only
(funcdecl 22 xrange 1 (functype (type 9) (type 2) (type 2)))

;; __init__ procedure for object
(methoddecl 23 __init__ 10 (functype (type 0) (type 10)))

(moduledecl 24 sys)

(localdecl 25 argv 24 (type 4))
(localdecl 26 stdin 24 (type 8))
(localdecl 27 stdout 24 (type 8))
(localdecl 28 stderr 24 (type 8))

(funcdecl 29 str 1 (functype (type 3) (type 0)))

;; The following functions aren't part of regular Python, which uses an
;; assortment of methods instead.  They're here just to make things a little
;; more interesting.

; close(F) closes file F.  Returns None
(funcdecl 30 close 1 (functype (type 0) (type 8)))

; append(L, x) destructively adds an element x to the end of a list L, 
; returning None.
(funcdecl 31 append 1 (functype (type 4) (type 4) (type 0)))

; extend(L1, L2) destructively appends L2 to L1, returning None.
(funcdecl 32 extend 1 (functype (type 4) (type 4) (type 4)))

; read(F) returns the entire contents of F as a string, as for f.read() in 
; Python.
(funcdecl 33 read 1 (functype (type 3) (type 8)))

; readline(F) returns the next line of F as a string, including the trailing 
; newline, as for F.readline() in Python.
(funcdecl 34 readline 1 (functype (type 3) (type 8)))
